package org.jeecg.modules.util;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.request.OapiSnsGetuserinfoBycodeRequest;
import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse;
import com.taobao.api.ApiException;
import org.jeecg.modules.config.Constant;

/**
 * @author 王鹏
 * @version 1.0
 * @description    根据获得的临时授权码来获取用户信息
 * @date 2020/8/9 1:14
 */
public class LoginUtil {
    public static OapiSnsGetuserinfoBycodeResponse  getLoginUserInfo(String code) throws ApiException {
        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode");
        OapiSnsGetuserinfoBycodeRequest req = new OapiSnsGetuserinfoBycodeRequest();
        req.setTmpAuthCode(code);
        OapiSnsGetuserinfoBycodeResponse response = client.execute(req, "dingqvsxqrsafiphodzf","harrzhhOzJj0KhMdIxMPcGpS6Xu9go9jZT49TB-gsYNoEFgCK8GBbPyU-YNtzxV7");
        return response;
    }
}
